package io.jft.doll.room.database

import android.arch.persistence.room.Database
import android.arch.persistence.room.Room
import android.arch.persistence.room.RoomDatabase
import com.g.base.appContent
import io.jft.doll.BuildConfig
import io.jft.doll.room.dao.AddressDao
import io.jft.doll.room.dao.RoomDao
import io.jft.doll.room.entity.common.AddressItemCEntity
import io.jft.doll.room.entity.common.AddressRegionCEntity
import io.jft.doll.room.entity.common.RoomCEntity

/**
 * Created by G on 2017/11/6 0006.
 */

@Database(version = BuildConfig.VERSION_CODE,
        entities =
        [
            AddressItemCEntity::class,
            AddressRegionCEntity::class,
            RoomCEntity::class
        ])
abstract class AppDatabase : RoomDatabase() {
    companion object {
        private const val DbName = "AppDatabase"
        val instant: AppDatabase by lazy {
            val databaseBuilder = Room.databaseBuilder<AppDatabase>(appContent, AppDatabase::class.java, DbName)
            databaseBuilder.fallbackToDestructiveMigration().allowMainThreadQueries().build()
        }
    }

    abstract fun getAddressDao(): AddressDao
    abstract fun getRoomDao(): RoomDao
}

